package io.renren.modules.noc.controller;

import java.util.Arrays;
import java.util.Map;

import io.renren.common.validator.ValidatorUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.noc.entity.NocLabelEntity;
import io.renren.modules.noc.service.NocLabelService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 标签表
 *
 * @author whc
 * @email hucheng_86@126.com
 * @date 2019-07-15 15:51:08
 */
@RestController
@RequestMapping("noc/noclabel")
public class NocLabelController {
    @Autowired
    private NocLabelService nocLabelService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("noc:noclabel:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = nocLabelService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    //@RequiresPermissions("noc:noclabel:info")
    public R info(@PathVariable("id") Integer id){
        NocLabelEntity nocLabel = nocLabelService.getById(id);

        return R.ok().put("nocLabel", nocLabel);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("noc:noclabel:save")
    public R save(@RequestBody NocLabelEntity nocLabel){
        nocLabelService.save(nocLabel);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("noc:noclabel:update")
    public R update(@RequestBody NocLabelEntity nocLabel){
        ValidatorUtils.validateEntity(nocLabel);
        nocLabelService.updateById(nocLabel);
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("noc:noclabel:delete")
    public R delete(@RequestBody Integer[] ids){
        nocLabelService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
